clear
rng default

%% Load useful matrices
load PXY_cond 
load V_CS
x=2;
PYX_cond_x=PXY_cond(x,:);
%m=1*10^6;
n=7^4;
p=n*(n-1)/2;
m=p;
random_indices_pairs = randperm(p, m).';
%% Construct grid
u0grid=0;
u1grid=V_CS(1,2);
gran=60; 
% try different values of gran and different sizes of grid hypercube as discussed in Appendix C of the paper (need powerful cluster to run the code for higher values of gran and larger sizes of hypercube)
u2grid=linspace(-15,15,gran); 
u3grid=linspace(-15,15,gran); 
u4grid=linspace(-15,15,gran); 
[ca, cb, cc,cd, ce] = ndgrid(u0grid, u1grid, u2grid, u3grid, u4grid);
u0grid=ca(:);
u1grid=cb(:);
u2grid=cc(:);
u3grid=cd(:);
u4grid=ce(:);

%% Workers
workers=500; %number of parallel workers
jobs=round(size(u2grid,1)/workers); %number of jobs per parallel worker

